package servlet;

import java.io.IOException;
import java.util.List;

import javax.security.auth.message.callback.PrivateKeyCallback.Request;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



import model.MeetingRoom;
import service.MeetingRoomService;
import service.impl.MeetingRoomServiceImpl;
//定义url访问形式
@WebServlet("/servlet/ViewAllMeetingRoomsServlet")
public class ViewAllMeetingRoomsServlet extends HttpServlet{
	
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// TODO 自动生成的方法存根
	//生成service层对象
	MeetingRoomService service=new MeetingRoomServiceImpl();
	//调用service层对象的方法
	List<MeetingRoom> list=service.viewAllMeetingRooms();
	//将从service层返回的数据赋值给属性meetingroomsList，准备带到jsp页面
	req.setAttribute("meetingroomsList", list);
	//这种页面的转向可以带参数，转到allmeetingrooms.jsp页面
	req.getRequestDispatcher("/jsp/allmeetingrooms.jsp").forward(req, resp);
	
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO 自动生成的方法存根
		doGet(req, resp);
	}

}
